/**
 * 关于星座的service层
 * @name: star.service
 * @data: 2024/5/29 11:11
 */
import {Provide} from "@midwayjs/core";
import {InjectEntityModel} from "@midwayjs/typeorm";
import {Repository} from "typeorm";
import Star from "../pojo/entity/star.entity";

@Provide()
export class StarService{
  @InjectEntityModel(Star)
  articleModel: Repository<Star>

  /**
   * @description 获取全部星座的数据
   */
  async selectAllStar(){
    return await this.articleModel.find();
  }

  /**
   * @description 根据星座id查询星座
   * @param starId
   */
  async selectStarById(starId:number){
    return await this.articleModel.findOneBy({starId});
  }

  /**
   * @description 根据name字段模糊查询
   * @param name
   */
  async selectStartByName(name: string) {
    return await this.articleModel.query(`select * from star where name like '%${name}%'`);
  }



}
